Skip to content

Sign out when login skips a workspace - #2

Merged
mattvagni merged 1 commit into
mainfrom
mattvagni/sign-out-skipped-workspace-d164
Oct 26, 2026
Merged

mattvagni merged 1 commit into
mainfrom
mattvagni/sign-out-skipped-workspace-d164

Conversation

@mattvagni

@mattvagni mattvagni commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Plain's sign-in screen asks which workspace to use, but it does not require an answer. Continuing without one issues a token with no workspace. The app then cannot load, and the next click on Sign in replays that same session, so the person lands back on the login page. Incognito works because it has no saved session.

This signs them out when that happens and clears the saved session so the next attempt starts clean.

  • If myWorkspace (or myUser) is null after sign-in, the app removes the user, stops silent renew, and deletes oidc state from sessionStorage and localStorage. clearStaleState only drops entries older than 15 minutes, which does not break this loop.
  • If the OAuth callback fails and would send them back to the sign-in page, it does the same cleanup first.
  • The next Sign in sends prompt=login and max_age=0, so Plain does not reuse the session that skipped the workspace. Plain's discovery document has no end-session endpoint to call. A later sign-in that does have a workspace clears that flag.
  • PKCE state is stored in sessionStorage with the user, matching the rest of the session. Older localStorage keys are still wiped.

Sign-in page after continuing without a workspace

workspace_signin_notice.mp4

Open in Web Open in Cursor 

Continuing past Plain's workspace step issues a token that cannot load the app, and the next sign-in replays that session. Drop the local user and OIDC state, and send prompt=login on the next attempt so the workspace step is shown again. Do the same when the callback bounces back to the sign-in page.

Co-authored-by: Mathias Vagni <mattvagni@users.noreply.github.com>
@vercel

vercel Bot commented Oct 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
example-headless-support-app Ready Ready Preview Oct 26, 2026 6:39pm UTC

Request Review

@mattvagni
mattvagni merged commit a2d2acc into main Oct 26, 2026
5 checks passed
@mpsq
mpsq deleted the mattvagni/sign-out-skipped-workspace-d164 branch October 26, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants